GBML manual / Rooms

Rooms and saving

A map of how a game is split into rooms and how it remembers anything between them and between plays - and which page covers which.

Two kinds of forgetting

A game forgets things in two different ways, and this section has a page for each.

  1. Leaving a room. Only one room is live at a time. When the player walks out of one, it is torn down, and coming back builds it fresh from the plan you made in the editor. (A room marked Persistent is the exception: the game keeps it while the player is away. See Persistent rooms.)
  2. Switching the console off. A game keeps everything in fast working memory, and that memory empties the moment the power goes.

Knowing which of the two you are fighting tells you which page you need.

You want toReadThe short version
Send the player to another room, pick the effect that hides the swap, or carry one thing acrossMoving between roomsA room is one space with a size, some tiles and the objects you placed in it. Only one is loaded at a time.
Know what a room is made of, and how doors workRoomsThe full list of what you place in a room, and what each setting does.
Play a scripted scene when the player walks into a roomCutscenesA cutscene is a timeline you build in the editor: camera moves, dialogue and effects. It takes over the game until it ends, and can be set to play only once.
Keep a value after the power is switched offSaving a gameA save is a copy of named values written into the cartridge's own battery-backed memory.

Which kind of remembering do you need?

The playerDoes the game need to remember it?Use
walks into the next room and comes backThe enemies they beat are back, because the room is rebuilt. To keep them beaten, write it down, or mark the room Persistent.a global variable, save_set, or a Persistent room
takes their character into the next roomOnly if that instance is marked persistent, or you carry it across with room_change_extpersistent
turns the console off and plays tomorrowOnly what you savedsave_set, then save_commit

The one mistake to avoid

save_set does not write to the cartridge. It only changes a working copy in memory. Nothing survives the power going off until you call save_commit. Saving a game explains why it is built this way.

Where to start

A first game usually needs Moving between rooms well before it needs saving. Read Saving a game when the game is long enough that a player would be upset to lose it.

See also: Moving between roomsSaving a gameRoomspersistentPersistent roomsroom_changesave_commit